

#include <opencv2/opencv.hpp>
using namespace cv;

#include <ros/ros.h>

#include <sensor_msgs/image_encodings.h>
#include <image_transport/image_transport.h>
#include <cv_bridge/cv_bridge.h>

#include "CaptureThread.h"


class CaptureThread::Private
{
public:
	ros::Publisher pub;
	ros::Subscriber sub;

};

CaptureThread::CaptureThread(int argc, char** argv, const std::string &name)
:
ThreadObject(argc, argv, name),
m_pPrivate(new Private)
{

}



void CaptureThread::msgReceivedCallback(const sensor_msgs::ImageConstPtr& msg) 
{
	ROS_INFO_STREAM("msgReceivedCallback");
	Mat mat = cv_bridge::toCvCopy(msg)->image;
	emit signalFrameAvailable(mat);
}

void CaptureThread::init()
{
	ros::NodeHandle n;
	m_pPrivate->sub = n.subscribe("/image", 10, &CaptureThread::msgReceivedCallback, this);
}

void CaptureThread::run()
{
	while(true) {
		sleep(1);
	}

}
